<template>
	<view>
		<view class="card" v-for="(item, index) in tableList" :key="index" >
			<view class="text-container">
				<view>
					<h3>{{ item.articleTitle }}</h3>
				</view>
				<view>
					<p>{{ item.createTime }}</p>
				</view>
			</view>
			<view class="image-container">
				<img style="width: 200rpx; height: 200rpx; object-fit: contain"
					src="../../static/images/banner/banner01.jpg" alt="Construction" />
			</view>
		</view>
		<view>
			<u-loadmore @loadmore="loadmore" :status="status" />
		</view>
	</view>
</template>

<script>
	import {
		safeThreeOnelist
	} from '@/api/article/index'
	import { Loading } from 'element-ui';
	export default {
		data() {
			return {
				status: "loadmore",
				tableList: [],
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
				},
				total:0,
			};
		},
		onLoad() {
			this.loadmore();

		},
		mounted() {
			this.list();
		},
		methods: {
			async list() {
				uni.showLoading({
            title: '加载中...',
            mask: true // 遮罩层
        });
				const {
					rows,
					code,
					msg,
					total
				} = await safeThreeOnelist(this.queryParams);
				if (code == 200) {
					// 将新加载的数据追加到现有的 tableList 中
					this.tableList = this.tableList.concat(rows);
					this.total = total;
					if (this.tableList.length == total) {
						this.status = "nomore";
					}
				}
			},
			loadmore() {
				this.queryParams.pageNum++;
				this.list();
			},
		},
	};
</script>

<style lang="scss">
	.card {
		display: flex;
		border: 1px solid #ddd;
		border-radius: 8px;
		overflow: hidden;
		height: 200rpx;
	}

	.image-container {
		flex: 1;
	}

	.image-container img {
		width: 100%;
		height: auto;
		border-radius: 50rpx 50rpx;
		/* 圆角效果 */
	}

	.text-container {
		flex: 2;
		padding: 10px;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.text-container h3 {
		margin: 0;
		font-size: 30rpx;
	}

	.text-container p {
		color: #888;
		font-size: 14px;
	}
</style>